PROJECT("GBDT")

SET(SRC_PATH "${PROJECT_SOURCE_DIR}")
SET(ROOT_PATH "${SRC_PATH}/../")

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
MESSAGE("Application: gbdt_train")

ADD_DEFINITIONS(
  "-D_MT"
  "-DDEBUG"
  "-D_REENTRANT"
  "-D_PTHREADS=6"
  "-D__STDC_FORMAT_MACROS"
  "-D__STDC_CONSTANT_MACROS"
  "-DLIB_03"
)

INCLUDE_DIRECTORIES(
${SRC_PATH}/
${SRC_PATH}/app
${SRC_PATH}/app/lr
${SRC_PATH}/app/lda
${SRC_PATH}/app/gbdt
${SRC_PATH}/app/maxent
${SRC_PATH}/app/svm
${SRC_PATH}/app/svd
${SRC_PATH}/optim
${SRC_PATH}/loader
${SRC_PATH}/type
${SRC_PATH}/common
${ROOT_PATH}/include
/usr/local/include/
)

LINK_DIRECTORIES(
${SRC_PATH}/lib
/usr/lib
/usr/local/lib
)

SET(LIBS
pthread
libgflags.a
#mpichcxx
#mpich
#mpl
mpi
)

#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -fopenmp -O3")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -openmp -O3")
SET(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS})
MESSAGE(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}")

SET(EXECUTABLE_OUTPUT_PATH "${ROOT_PATH}/bin")

SET(GBDT_SRC_LIST
	${SRC_PATH}/main/gbdt_train.cc
	${SRC_PATH}/loader/data_loader.cc
	${SRC_PATH}/app/gbdt/gbdt_core.cc
	${SRC_PATH}/app/gbdt/gbdt_para.cc
	${SRC_PATH}/app/gbdt/tree.cc
)

ADD_EXECUTABLE(gbdt_train ${GBDT_SRC_LIST})
TARGET_LINK_LIBRARIES(gbdt_train ${LIBS})

SET(LDA_SRC_LIST
	${SRC_PATH}/main/lda_train.cc
	${SRC_PATH}/app/lda/lda_core.cc
	${SRC_PATH}/loader/simple_loader.cc
)

ADD_EXECUTABLE(lda_train ${LDA_SRC_LIST})
TARGET_LINK_LIBRARIES(lda_train ${LIBS})

SET(LR_SRC_LIST
	${SRC_PATH}/loader/pvclick_loader.cc
	${SRC_PATH}/main/lr_train.cc
	${SRC_PATH}/app/lr/lr_core.cc
	${SRC_PATH}/type/vec_util.cc
	${SRC_PATH}/optim/owlqn.cc
	${SRC_PATH}/optim/termination.cc
)

ADD_EXECUTABLE(lr_train ${LR_SRC_LIST})
TARGET_LINK_LIBRARIES(lr_train ${LIBS})

SET(ME_SRC_LIST
	${SRC_PATH}/loader/class_loader.cc
	${SRC_PATH}/optim/lbfgs.cc
	${SRC_PATH}/app/maxent/lbfgs_trainer.cc
	${SRC_PATH}/app/maxent/maxent_core.cc
	${SRC_PATH}/main/maxent_train.cc
)

ADD_EXECUTABLE(maxent_train ${ME_SRC_LIST})
TARGET_LINK_LIBRARIES(maxent_train ${LIBS})

SET(SVM_SRC_LIST
	${SRC_PATH}/common/timer.cc
	${SRC_PATH}/app/svm/impl/util.cc
	${SRC_PATH}/app/svm/svm_core.cc
	${SRC_PATH}/app/svm/impl/document.cc
	${SRC_PATH}/app/svm/impl/io.cc
	${SRC_PATH}/app/svm/impl/kernel.cc
	${SRC_PATH}/app/svm/impl/matrix_manipulation.cc
	${SRC_PATH}/app/svm/impl/matrix.cc
	${SRC_PATH}/app/svm/impl/model.cc
	${SRC_PATH}/app/svm/impl/parallel_interface.cc
	${SRC_PATH}/app/svm/impl/pd_ipm.cc
	${SRC_PATH}/main/svm_train.cc
)

ADD_EXECUTABLE(svm_train ${SVM_SRC_LIST})
TARGET_LINK_LIBRARIES(svm_train ${LIBS})

SET(SVD_SRC_LIST
	${SRC_PATH}/app/svd/svd_core.cc
	${SRC_PATH}/app/svd/svd_trainer.cc
	${SRC_PATH}/app/svd/svd_data.cc
	${SRC_PATH}/main/svd_train.cc
)

ADD_EXECUTABLE(svd_train ${SVD_SRC_LIST})
TARGET_LINK_LIBRARIES(svd_train ${LIBS})

